package com.chenglai.seckill.dao;

import com.chenglai.seckill.pojo.GroupOnInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;
import tk.mybatis.mapper.common.MySqlMapper;

/**
 * 类描述：
 *
 * @Author rxh
 * @Date 2023/11/27 10:39
 */
@Repository
public interface GroupOnInfoMapper extends Mapper<GroupOnInfo>, MySqlMapper<GroupOnInfo> {

    @Select("select group_Id from t_cl_gorupOn_Info where goods_id = #{goodsId} and shop_id = #{shopId} and status = 0")
    Integer queryGroupOnId(Integer goodsId, Integer shopId);

    @Update("UPDATE t_cl_groupOn_Info set status = #{status} where group_id = #{groupId}")
    void updateStatus(Integer status, Integer groupId);

    @Insert("insert into t_cl_gorupOn_Info values (#{groupName},#{goodsId},#{shopId},#{userId},#{startTime},#{endTime},#{status})")
    @Options(useGeneratedKeys = true, keyProperty = "groupInfoId")
    void addGroupOnInfo(GroupOnInfo groupOnInfo);

}
